#!/user/bin/env python3
# -*- coding: utf-8 -*-
#-- author bluedolphi --
import xadmin
from app.models import Saleman, SalemanTeam, CustomerServicer, Enterprise, GasStation, GasStationOnline, \
    GasStationOffline, GasStationTrain, GasStationPayments, WxworkGroupy, GasStationDayReport
from xadmin.views import BaseAdminView, CommAdminView
from app.views import ThemeSetting, CustomView
from daterange_filter.filter import DateRangeFilter

xadmin.site.register(BaseAdminView,ThemeSetting)#对配置进行注册
xadmin.site.register(CommAdminView,CustomView)

class SalemanTeamAdmin(object):
    list_display = ('id','name',"get_team_nums","base_action")
    list_filter = ()
    list_display_links = ('name')
    search_fields = ('name', )
    list_editable =()
    ordering = ('name',)
    list_per_page = 10
    #refresh_time =[5,7]

class SalemanAdmin(object):
    list_display = ('salemanTeam','name',"wxid","wxword_id",)
    list_filter = ('salemanTeam__name',)
    raw_id_fields=('salemanTeam')
    list_display_links = ( 'name',"wxid",)
    search_fields = ('salemanTeam','name', 'wxid',"wxword_id")
    list_editable =[]
    ordering = ('name',)
    list_per_page = 10
    relfield_style = 'fk-ajax'
    #refresh_time =[5,7]

class CustomerServicerAdmin(object):
    list_display = ('id','name',"wxid","wxword_id","get_enterprise_nums","get_gasStation_nums")
    list_filter = ()
    list_display_links = ('name')
    search_fields = ('name',"wxid","wxword_id")
    list_editable =()
    ordering = ('name',)
    list_per_page = 10

class EnterpriseAdmin(object):
    list_display = ('id', 'name', "address","get_gasStation_nums","saleman","customerServicer","server_site")
    list_filter = ()
    list_display_links = ('name')
    search_fields = ('name',)
    list_editable = ()
    ordering = ('-createdtime',)
    list_per_page = 10

class GasStationAdmin(object):
    list_display = ('id', 'name', "address", "saleman","customerServicer","server_site","status")
    list_filter = ("customerServicer","server_site","status")
    list_display_links = ('name')
    search_fields = ('name',)
    list_editable = ()
    ordering = ('create_date',)
    list_per_page = 10

class GasStationOnlineAdmin(object):
    list_display = ('id', 'gasStation', "online_date", "online_type", "online_reason")
    list_filter = ()
    list_display_links = ('gasStation')
    search_fields = ('gasStation',)
    list_editable = ()
    ordering = ('gasStation',)
    list_per_page = 10

class GasStationOfflineAdmin(object):
    list_display = ('id', 'gasStation', "offline_date", "offline_type", "offline_reason")
    list_filter = ()
    list_display_links = ('gasStation')
    search_fields = ('gasStation',)
    list_editable = ()
    ordering = ('gasStation',)
    list_per_page = 10

class GasStationTrainAdmin(object):
    list_display = ('id', 'gasStation', "train_date", "trainer", "cost_of_training")
    list_filter = ()
    list_display_links = ('gasStation')
    search_fields = ('gasStation',)
    list_editable = ()
    ordering = ('gasStation',)
    list_per_page = 10



class GasStationPaymentsAdmin(object):
    list_display = ('id', 'gasStation', "payment_date", "payment", "memo")
    list_filter = ()
    list_display_links = ('gasStation')
    search_fields = ('gasStation',)
    list_editable = ()
    ordering = ('gasStation',)
    list_per_page = 10


class WxworkGroupyAdmin(object):
    list_display = ('id', 'roomName','new_room_name','member_count', 'adminName',"createtime")
    list_filter = ()
    list_display_links = ('id')
    search_fields = ( 'roomName','new_room_name', 'adminName')
    list_editable = ()
    ordering = ('roomName',"member_count","createtime")
    list_per_page = 10

class GasStationDayReportAdmin(object):
    list_display = ('id', 'date','gasStation','turnover', 'yestoday_turnover',"gasStation_customerServicer")
    #readonly_fields=('id', 'date','gasStation','turnover', 'yestoday_turnover',"gasStation_customerServicer")
    #list_filter = [("date", DateRangeFilter)]
    search_fields = ('date')

    list_per_page = 10


xadmin.site.register(SalemanTeam, SalemanTeamAdmin)
xadmin.site.register(Saleman, SalemanAdmin)
xadmin.site.register(CustomerServicer, CustomerServicerAdmin)
xadmin.site.register(Enterprise, EnterpriseAdmin)
xadmin.site.register(GasStation, GasStationAdmin)

xadmin.site.register(GasStationOnline, GasStationOnlineAdmin)
xadmin.site.register(GasStationOffline, GasStationOfflineAdmin)
xadmin.site.register(GasStationTrain, GasStationTrainAdmin)
xadmin.site.register(GasStationPayments, GasStationPaymentsAdmin)

xadmin.site.register(WxworkGroupy, WxworkGroupyAdmin)
xadmin.site.register(GasStationDayReport, GasStationDayReportAdmin)
